<?php
namespace Plug;
defined('IN_IA') or exit('Access Denied');
class Plug
{
    const DEFEND = "defend";   //酷源防封

    public $Plugin = null;  //指定插件对象
    private $_plugs = array(    //各个插件相关信息
        "defend"=>array(    //酷源防封
            "table"=>"kuyuan_defend_domain"    //验证数据表
        )
    );

    private $_plug = array();   //当前插件相关信息

    private $_result = array();  //返回数据

    /**
     * Plug constructor.
     * @param $_plug_name  模块标识
     */
    public function __construct($_plug_name)
    {
        $this->_plug = $this->_plugs[$_plug_name];
        $_className = "Plug\\".$_plug_name."\\action\\".ucwords($_plug_name)."PlugAction";
        call_user_func(function($arg1,$arg2){
            $arg1->Plugin = new $arg2();
        },$this,$_className);
    }

    /**
     * 验证是否可以使用插件，查询插件的一个相关数据表
     */
    public function check()
    {
        return pdo_tableexists($this->_plug["table"]);
    }

    public function get()
    {
        return $this->Plugin;
    }
}
